#include <bits/stdc++.h>
// 2025/02/03
// tag:
// Author: Zhang Muen
using namespace std;

int R[200002], r[200002], l[200002];
char a[200002];

int main()
{
    string s;
    cin >> s;
    int si = 2;
    a[1] = '$', a[2] = '#';
    for (int i = 0; i < s.size(); i++)
        a[++si] = s[i], a[++si] = '#';
    int p = 0, mx = 0;
    for (int i = 1; i <= si; i++) {
        if (mx >= i)
            R[i] = min(R[2 * p - i], mx - i);
        else
            R[i] = 1;
        while (a[i + R[i]] == a[i - R[i]])
            R[i]++;
        if (i + R[i] > mx)
            p = i, mx = i + R[i];
        l[i + R[i] - 1] = max(l[i + R[i] - 1], R[i] - 1);
        r[i - R[i] + 1] = max(r[i - R[i] + 1], R[i] - 1);
    }
    for (int i = 2; i <= si; i += 2)
        r[i] = max(r[i - 2] - 2, r[i]);
    for (int i = si; i >= 2; i -= 2)
        l[i] = max(l[i + 2] - 2, l[i]);
    int ans = 0;
    for (int i = 2; i <= si; i += 2)
        if (r[i] && l[i])
            ans = max(ans, r[i] + l[i]);
    cout << ans;
}
